<template>
	<slot :controller="controller" :store="store" :model="model">
		<AppForm
			ref="editForm"
			v-bind="$attrs"
			:id="controlID"
			:name="model.codeName"
			:class="classNames"
			:data="store.data"
		>
			<AppAnchor
				v-if="store.anchorData.length > 0"
				:controlID="controlID"
				:anchorData="store.anchorData"
			/>
			<div class="control-content app-control-form__content">
				<AppRow :layoutOpts="{ selfLayout: 'TABLE_24COL' }">
					<AppCol
						noRoot
						:visible="store.detailModel.group1.visible"
						:layoutOpts="{
							selfLayout: 'TABLE_24COL',
							parentLayout: 'TABLE_24COL',
							colMD: 24,
						}"
					>
						<template #default="{ slotClass, slotStyle }">
							<slot
								name="group1"
								:controller="controller"
								:store="store"
								:model="model"
								:slotClass="slotClass"
								:slotStyle="slotStyle"
								:actions="{ handleComponentAction }"
							>
								<AppFormGroup
									name="group1"
									v-show="store.detailModel.group1.visible"
									:slotClass="slotClass"
									:slotStyle="slotStyle"
									:layoutOpts="{
										selfLayout: 'TABLE_24COL',
										parentLayout: 'TABLE_24COL',
										colMD: 24,
									}"
									:title="
										$t(
											'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.GROUPPANEL.GROUP1',
											'外部认证基本信息'
										)
									"
									subCaption=""
									:enableAnchor="false"
									:showMoreItems="store.detailModel.group1.showMoreItems"
									:showMoreMode="store.detailModel.group1.showMoreMode"
									:infoGroupMode="false"
									:titleBarCloseMode="0"
									:showCaption="false"
									:uIActionGroup="store.detailModel.group1.uIActionGroup"
									@component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
								>
									<AppCol
										noRoot
										:visible="store.detailModel.grouppanel1.visible"
										:layoutOpts="{
											selfLayout: 'TABLE_24COL',
											parentLayout: 'TABLE_24COL',
											colMD: 24,
										}"
									>
										<template #default="{ slotClass, slotStyle }">
											<slot
												name="grouppanel1"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormGroup
													name="grouppanel1"
													v-show="store.detailModel.grouppanel1.visible"
													:slotClass="slotClass"
													:slotStyle="slotStyle"
													:layoutOpts="{
														selfLayout: 'TABLE_24COL',
														parentLayout: 'TABLE_24COL',
														colMD: 24,
													}"
													:title="
														$t(
															'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.GROUPPANEL.GROUPPANEL1',
															'请求配置'
														)
													"
													subCaption=""
													:enableAnchor="false"
													:showMoreItems="
														store.detailModel.grouppanel1.showMoreItems
													"
													:showMoreMode="
														store.detailModel.grouppanel1.showMoreMode
													"
													:infoGroupMode="false"
													:titleBarCloseMode="0"
													:showCaption="true"
													:uIActionGroup="
														store.detailModel.grouppanel1.uIActionGroup
													"
													@component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
												>
													<AppCol
														noRoot
														:visible="store.detailModel.id.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="id"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="id"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t('DEF.LNAME.AUTH_PROVIDER.ID', '应用标识')
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="store.detailModel.id.valueRule"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="idEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{ editorType: 'TEXTBOX' }"
																				type="text"
																				style=""
																				name="id"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel.id.disabled
																				"
																				:value="store.data.id"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="store.detailModel.name.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="name"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="name"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.FORMITEM.NAME',
																			'应用名称'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="store.detailModel.name.valueRule"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="nameEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{ editorType: 'TEXTBOX' }"
																				type="text"
																				style=""
																				name="name"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel.name.disabled
																				"
																				:value="store.data.name"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="
															store.detailModel.authentication_uri.visible
														"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="authentication_uri"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="authentication_uri"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'DEF.LNAME.AUTHENTICATION_URI',
																			'认证地址'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="
																		store.detailModel.authentication_uri
																			.valueRule
																	"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="authentication_uriEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{ editorType: 'TEXTBOX' }"
																				type="text"
																				style=""
																				name="authentication_uri"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel.authentication_uri
																						.disabled
																				"
																				:value="store.data.authentication_uri"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="
															store.detailModel.authentication_method.visible
														"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="authentication_method"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="authentication_method"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.FORMITEM.AUTHENTICATION_METHOD',
																			'认证方式'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="
																		store.detailModel.authentication_method
																			.valueRule
																	"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="authentication_methodEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppDropdownList
																				codeListTag="authentication__Auth_provider_request_method"
																				codeListType="STATIC"
																				v-bind="{ editorType: 'DROPDOWNLIST' }"
																				:multiple="false"
																				:context="store.context"
																				:viewParams="store.viewParams"
																				style=""
																				name="authentication_method"
																				:disabled="
																					store.detailModel
																						.authentication_method.disabled
																				"
																				:value="
																					store.data.authentication_method
																				"
																				:data="store.data"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="store.detailModel.disabled.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="disabled"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="disabled"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	label="是否禁用"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="store.detailModel.disabled.valueRule"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="disabledEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppSwitch
																				v-bind="{ editorType: 'SWITCH' }"
																				style=""
																				name="disabled"
																				:disabled="
																					store.detailModel.disabled.disabled
																				"
																				:value="store.data.disabled"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="store.detailModel.sort.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="sort"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="sort"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="$t('DEF.LNAME.SORT', '排序')"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="store.detailModel.sort.valueRule"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="sortEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{ editorType: 'TEXTBOX' }"
																				type="text"
																				style=""
																				name="sort"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel.sort.disabled
																				"
																				:value="store.data.sort"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="store.detailModel.base_config.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 24,
															colMD: 24,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="base_config"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="base_config"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.FORMITEM.BASE_CONFIG',
																			'认证基础配置'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="
																		store.detailModel.base_config.valueRule
																	"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="base_configEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{
																					editorType: 'TEXTAREA_10',
																					HEIGHT: 200,
																				}"
																				:isTextArea10="true"
																				type="textarea"
																				style="height: 200px"
																				name="base_config"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel.base_config.disabled
																				"
																				:value="store.data.base_config"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
												</AppFormGroup>
											</slot>
										</template>
									</AppCol>
									<AppCol
										noRoot
										:visible="store.detailModel.grouppanel2.visible"
										:layoutOpts="{
											selfLayout: 'TABLE_24COL',
											parentLayout: 'TABLE_24COL',
											colMD: 24,
										}"
									>
										<template #default="{ slotClass, slotStyle }">
											<slot
												name="grouppanel2"
												:controller="controller"
												:store="store"
												:model="model"
												:slotClass="slotClass"
												:slotStyle="slotStyle"
												:actions="{ handleComponentAction }"
											>
												<AppFormGroup
													name="grouppanel2"
													v-show="store.detailModel.grouppanel2.visible"
													:slotClass="slotClass"
													:slotStyle="slotStyle"
													:layoutOpts="{
														selfLayout: 'TABLE_24COL',
														parentLayout: 'TABLE_24COL',
														colMD: 24,
													}"
													:title="
														$t(
															'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.GROUPPANEL.GROUPPANEL2',
															'响应配置'
														)
													"
													subCaption=""
													:enableAnchor="false"
													:showMoreItems="
														store.detailModel.grouppanel2.showMoreItems
													"
													:showMoreMode="
														store.detailModel.grouppanel2.showMoreMode
													"
													:infoGroupMode="false"
													:titleBarCloseMode="0"
													:showCaption="true"
													:uIActionGroup="
														store.detailModel.grouppanel2.uIActionGroup
													"
													@component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
												>
													<AppCol
														noRoot
														:visible="store.detailModel.response_type.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="response_type"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="response_type"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.FORMITEM.RESPONSE_TYPE',
																			'响应类型'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="
																		store.detailModel.response_type.valueRule
																	"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="response_typeEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppDropdownList
																				codeListTag="authentication__Auth_provider_response_type"
																				codeListType="STATIC"
																				v-bind="{ editorType: 'DROPDOWNLIST' }"
																				:multiple="false"
																				:context="store.context"
																				:viewParams="store.viewParams"
																				style=""
																				name="response_type"
																				:disabled="
																					store.detailModel.response_type
																						.disabled
																				"
																				:value="store.data.response_type"
																				:data="store.data"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="
															store.detailModel.response_success_flag.visible
														"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 12,
															colMD: 12,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="response_success_flag"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="response_success_flag"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'CONTROL.DEFORM.AUTH_PROVIDER.MAIN.FORMITEM.RESPONSE_SUCCESS_FLAG',
																			'响应成功标记'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="
																		store.detailModel.response_success_flag
																			.valueRule
																	"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="response_success_flagEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{ editorType: 'TEXTBOX' }"
																				type="text"
																				style=""
																				name="response_success_flag"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel
																						.response_success_flag.disabled
																				"
																				:value="
																					store.data.response_success_flag
																				"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
													<AppCol
														noRoot
														:visible="store.detailModel.response_config.visible"
														:layoutOpts="{
															parentLayout: 'TABLE_24COL',
															colLG: 24,
															colMD: 24,
														}"
													>
														<template v-slot:default="{ slotStyle, slotClass }">
															<slot
																name="response_config"
																:controller="controller"
																:store="store"
																:model="model"
																:slotClass="slotClass"
																:slotStyle="slotStyle"
																:actions="{ handleComponentAction }"
															>
																<AppFormItem
																	name="response_config"
																	:slotStyle="slotStyle"
																	:slotClass="slotClass"
																	:label="
																		$t(
																			'DEF.LNAME.RESPONSE_CONFIG',
																			'认证响应配置'
																		)
																	"
																	labelPos="LEFT"
																	:labelWidth="130"
																	:showLabel="true"
																	:enableAnchor="false"
																	:rules="
																		store.detailModel.response_config.valueRule
																	"
																	:emptyCaption="false"
																>
																	<div class="form-editor-container">
																		<slot
																			name="response_configEditor"
																			:controller="controller"
																			:store="store"
																			:model="model"
																			:actions="{ handleComponentAction }"
																		>
																			<AppInput
																				v-bind="{
																					editorType: 'TEXTAREA_10',
																					HEIGHT: 200,
																				}"
																				:isTextArea10="true"
																				type="textarea"
																				style="height: 200px"
																				name="response_config"
																				:isDebounce="false"
																				:disabled="
																					store.detailModel.response_config
																						.disabled
																				"
																				:value="store.data.response_config"
																				@component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
																			/>
																		</slot>
																	</div>
																</AppFormItem>
															</slot>
														</template>
													</AppCol>
												</AppFormGroup>
											</slot>
										</template>
									</AppCol>
								</AppFormGroup>
							</slot>
						</template>
					</AppCol>
				</AppRow>
			</div>
		</AppForm>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{spinalCase ctrl.codeName}}-form-base.vue.hbs生成

import { Ref } from 'vue';
import { AppAnchor } from '@components/common/anchor';
import { AppCol } from '@/components/common/col';
import { AppRow } from '@/components/common/row';
import {
	AppForm,
	AppFormPage,
	AppFormGroup,
	AppFormTabPage,
	AppFormItem,
	AppFormButton,
	AppFormDruipart,
	AppFormIframe,
	AppFormRaw,
	AppFormMdCtrl,
	AppFormMdCtrlRepeater,
} from '@components/widgets/form';
import {
	IEvent,
	EditFormActionType,
	IEditFormAbility,
	IEditFormStore,
	IParam,
} from '@/core';
import { useProps, useBasic, useAction, useController } from './api-form-hook';

const editForm: Ref = ref(null);

// 输入参数
const props = defineProps(useProps());

// 基础数据
const {
	controlID,
	getClassNames,
	model,
	useNavParamsBind,
	useEventBind,
	handleActionClick,
	handleComponentAction,
} = useBasic(props);

const emit = defineEmits<{
	(
		event: 'ctrl-action',
		name: string,
		action: EditFormActionType,
		data: IParam[]
	): void;
	(event: 'ctrl-init', name: string, data: IEditFormAbility): void;
	(event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
	return getClassNames(props);
});

//  表单控制器
const controller = useController(props, evt, { controlID, editForm });

useNavParamsBind(controller, props);

const store: IEditFormStore = controller.getStore();

const ctrlService = controller.getCtrlService();

onMounted(() => {
	controller.ctrlMounted();
});
onUnmounted(() => {
	controller.ctrlDestroy();
});
</script>
